package com.lancoo.znbkxx.teacher.model.repository

import com.lancoo.znbkxx.teacher.Ext.Companion.BASE_URL
import com.lancoo.znbkxx.teacher.Ext.Companion.BASE_URL_COMMENT
import com.lancoo.znbkxx.teacher.model.api.BaseRepository
import com.lancoo.znbkxx.teacher.model.api.ZnbkRetrofitClient
import com.lancoo.znbkxx.teacher.model.data.*
import com.lancoo.znbkxx.teacher.service.SystemService

/**
 * @author : Admin
 * @date   : 2019/7/24 9:11
 * @desc   :
 */
class SystemRepository : BaseRepository() {
    suspend fun getSystemConfigInfo(platform: Int, subjectId: String, token: String,
            userID: String): ZnbkResponse<SystemInfo> {
        val service = ZnbkRetrofitClient.getService(SystemService::class.java, BASE_URL)
        return request { service.getSystemConfigInfo(platform, subjectId, token, userID) }
    }

    suspend fun getSystemConfigInfoComment(platform: Int, subjectId: String, token: String,
            userID: String): ZnbkResponse<SystemInfo> {
        val service = ZnbkRetrofitClient.getService(SystemService::class.java, BASE_URL_COMMENT)
        return request { service.getSystemConfigInfoComment(platform, subjectId, token, userID) }
    }

    suspend fun getBaseInfo(courseNo: String, token: String, userID: String,
            subjectID: String): ZnbkResponse<MutableList<BaseInfo>> {
        val service = ZnbkRetrofitClient.getService(SystemService::class.java, BASE_URL)
        return request { service.getCourseClassList(courseNo, token, userID, subjectID) }
    }

    suspend fun getObsInfo(): CoursewareOBSInfo {
        val service = ZnbkRetrofitClient.getService(SystemService::class.java, BASE_URL_COMMENT)
        return request { service.getObsInfo() }
    }
}